/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkl51.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import pkl51.entity.Blok4;
import pkl51.error.EntityException;
import pkl51.service.Blok4Dao;
import pkl51.service.impl.Blok4DaoImpl;

/**
 *
 * @author Hindarwan
 */
public class Blok4RowModel implements Serializable {
    
    private static final long serialVersionUID = 5455270872075694017L;
    private String nks;
    private String b4C1;
    private String b4C2;
    private String b4C3;
    private String b4C4;
    private String b4C5;
    private String b4C6;
    private String b4C7;
    private String b4C8;
    private String b4C9;
    private String b4C10;
    private String b4C11;
    private String b4C12;
    private PropertyChangeSupport propertySupport;

    public Blok4RowModel() {
        this.nks = Blok123Model.getInstance().getNKS();
        propertySupport = new PropertyChangeSupport(this);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }

    public void insertBlok4Row() throws EntityException {
        this.nks = Blok123Model.getInstance().getNKS();
        Blok4Dao dao = new Blok4DaoImpl();
        dao.insertBlok4(new Blok4(nks, b4C1, b4C2, b4C3, b4C4, Integer.valueOf(b4C5), b4C6, b4C7, b4C8, b4C9, b4C10, b4C11, b4C12));
    }

    public void updateBlok4Row() throws EntityException {
        this.nks = Blok123Model.getInstance().getNKS();
        Blok4Dao dao = new Blok4DaoImpl();
        dao.updateBlok4(new Blok4(nks, b4C1, b4C2, b4C3, b4C4, Integer.valueOf(b4C5), b4C6, b4C7, b4C8, b4C9, b4C10, b4C11, b4C12));
    }

    public void getBlok4Row() throws EntityException {
        this.nks = Blok123Model.getInstance().getNKS();
        Blok4Dao dao = new Blok4DaoImpl();
        Blok4 blok4 = dao.getBlok4ByNksB4C1(nks, b4C1);

        setB4C2(blok4.getB4C2());
        setB4C3(blok4.getB4C3());
        setB4C4(blok4.getB4C4());
        setB4C5(String.valueOf(blok4.getB4C5()));
        setB4C6(blok4.getB4C6());
        setB4C7(blok4.getB4C7());
        setB4C8(blok4.getB4C8());
        setB4C9(blok4.getB4C9());
        setB4C10(blok4.getB4C10());
        setB4C11(blok4.getB4C11());
        setB4C12(blok4.getB4C12());

    }

    public void setNks(String nks) {
        String old = this.nks;
        this.nks = nks;
        propertySupport.firePropertyChange("nks", old, this.nks);
    }

    public void setB4C1(String b4C1) {
        String old = this.b4C1;
        this.b4C1 = b4C1;
        propertySupport.firePropertyChange("b4C1", old, this.b4C1);
    }

    public void setB4C2(String b4C2) {
        String old = this.b4C2;
        this.b4C2 = b4C2;
        propertySupport.firePropertyChange("b4C2", old, this.b4C2);
    }

    public void setB4C3(String b4C3) {
        String old = this.b4C3;
        this.b4C3 = b4C3;
        propertySupport.firePropertyChange("b4C3", old, this.b4C3);
    }

    public void setB4C4(String b4C4) {
        String old = this.b4C4;
        this.b4C4 = b4C4;
        propertySupport.firePropertyChange("b4C4", old, this.b4C4);
    }

    public void setB4C5(String b4C5) {
        String old = this.b4C5;
        this.b4C5 = b4C5;
        propertySupport.firePropertyChange("b4C5", old, this.b4C5);
    }

    public void setB4C6(String b4C6) {
        String old = this.b4C6;
        this.b4C6 = b4C6;
        propertySupport.firePropertyChange("b4C6", old, this.b4C6);
    }

    public void setB4C7(String b4C7) {
        String old = this.b4C7;
        this.b4C7 = b4C7;
        propertySupport.firePropertyChange("b4C7", old, this.b4C7);
    }

    public void setB4C8(String b4C8) {
        String old = this.b4C8;
        this.b4C8 = b4C8;
        propertySupport.firePropertyChange("b4C8", old, this.b4C8);
    }

    public void setB4C9(String b4C9) {
        String old = this.b4C9;
        this.b4C9 = b4C9;
        propertySupport.firePropertyChange("b4C9", old, this.b4C9);
    }

    public void setB4C10(String b4C10) {
        String old = this.b4C10;
        this.b4C10 = b4C10;
        propertySupport.firePropertyChange("b4C10", old, this.b4C10);
    }

    public void setB4C11(String b4C11) {
        String old = this.b4C11;
        this.b4C11 = b4C11;
        propertySupport.firePropertyChange("b4C11", old, this.b4C11);
    }

    public void setB4C12(String b4C12) {
        String old = this.b4C12;
        this.b4C12 = b4C12;
        propertySupport.firePropertyChange("b4C12", old, this.b4C12);
    }

    public String getNks() {
        return nks;
    }

    public String getB4C1() {
        return b4C1;
    }

    public String getB4C2() {
        return b4C2;
    }

    public String getB4C3() {
        return b4C3;
    }

    public String getB4C4() {
        return b4C4;
    }

    public String getB4C5() {
        return b4C5;
    }

    public String getB4C6() {
        return b4C6;
    }

    public String getB4C7() {
        return b4C7;
    }

    public String getB4C8() {
        return b4C8;
    }

    public String getB4C9() {
        return b4C9;
    }

    public String getB4C10() {
        return b4C10;
    }

    public String getB4C11() {
        return b4C11;
    }

    public String getB4C12() {
        return b4C12;
    }
    
    public void resetModel(){
        setNks("");
        setB4C2("");
        setB4C3("");
        setB4C4("");
        setB4C5("");
        setB4C6("");
        setB4C7("");
        setB4C8("");
        setB4C9("");
        setB4C10("");
        setB4C11("");
        setB4C12("");
    }
}
